package org.hzy.loggs;

import java.util.Date;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
import org.hibernate.SessionFactory;
import org.hzy.entity.TLog;
import org.hzy.entity.TUser;
import org.hzy.services.IUserLoginService;
import org.hzy.services.impl.UserLoginService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class LoginLogg implements MethodInterceptor{
	private static Logger l=Logger.getLogger(LoginLogg.class);
		private SessionFactory sf;
		
	
		public static Logger getL() {
			return l;
		}

		public static void setL(Logger l) {
			LoginLogg.l = l;
		}

		public SessionFactory getSf() {
			return sf;
		}

		public void setSf(SessionFactory sf) {
			this.sf = sf;
		}

		public Object invoke(MethodInvocation arg0) throws Throwable {
		// TODO Auto-generated method stub
		System.out.println("this invoke");
		System.out.println("Start");
		this.sf.getCurrentSession().beginTransaction();
		Object obj=arg0.proceed();
		this.sf.getCurrentSession().getTransaction().commit();
		System.out.println("guan");
		return obj;
	}
//	public Object around(ProceedingJoinPoint pjp) throws Throwable{
//		System.out.println("this is doAround"+this.getIu());
//		Object obj=pjp.proceed();
//		return obj;
//	}
	
	public static void main(String[] args) {
		ApplicationContext ctx=new ClassPathXmlApplicationContext("beans1.xml");
		LoginLogg lo=ctx.getBean("logadvice",LoginLogg.class);
	}
	
}
